<template>
  <div class="app-container">
      <el-row>
        <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="80px">
          <el-col>
          <el-form-item label="姓名" prop="name">
            <el-input
              v-model="queryParams.name"
              placeholder="请输入姓名"
              clearable
              size="small"
              style="width: 240px"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="身份证" prop="cardId">
            <el-input
              v-model="queryParams.cardId"
              placeholder="请输入身份证"
              clearable
              size="small"
              style="width: 240px"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="手机号" prop="shone">
            <el-input
              v-model="queryParams.shone"
              placeholder="请输入手机号"
              clearable
              size="small"
              style="width: 240px"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          </el-col>
          
          <el-form-item label="性别" prop="sex">
            <el-select v-model="queryParams.sex" placeholder="请选择性别"
              size="small"
              style="width: 240px">
                <el-option key="1" label="男" value="男"></el-option>
                <el-option key="2" label="女" value="女"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="入职项目" prop="entryProgram">
            <el-input
              v-model="queryParams.entryProgram"
              placeholder="请输入入职项目"
              clearable
              size="small"
              style="width: 240px"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="所属单位" prop="company_id">
            <el-select
              v-model="queryParams.company_id"
              placeholder="所属单位"
              clearable
              size="small"
              style="width: 240px"
            >
              <el-option
                v-for="item in companyOptions"
                :key="item.ID"
                :label="item.Name"
                :value="item.ID"
                ></el-option>
            </el-select>
          </el-form-item>
          <el-col v-if="isExpand">
          <el-form-item label="所属人" prop="user_id">
            <el-select
              v-model="queryParams.user_id"
              placeholder="所属人"
              clearable
              size="small"
              style="width: 240px"
            >
              <el-option
                v-for="item in peoplesOptions"
                :key="item.ID"
                :label="item.UserName"
                :value="item.ID"
                ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="状态" prop="statusId">
            <el-select
              v-model="queryParams.statusId"
              placeholder="状态"
              clearable
              size="small"
              style="width: 240px"
            >
              <el-option
                v-for="item in statusOptions"
                :key="item.Id"
                :label="item.Name"
                :value="item.Id"
                ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="时间">
            <el-date-picker
              v-model="dateRange"
              size="small"
              style="width: 240px"
              value-format="yyyy-MM-dd"
              type="daterange"
              range-separator="-"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            ></el-date-picker>
          </el-form-item>
          </el-col>
          <el-col :span="20" align="right">
          <el-form-item>
            <span style="color:#a4da89;cursor:pointer;padding-right:10px;" @click="isExpand=!isExpand"><i color="#a4da89" :class="isExpand?'el-icon-arrow-down':'el-icon-arrow-up'">
            </i>{{isExpand?'收起':'展开'}}</span>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
          </el-col>
        </el-form>
      </el-row>
        <el-row :gutter="10" class="mb8">
          <el-col :span="12">
            <el-col :span="1.5" v-if="$store.state.currentJur.isAdd">
              <el-button
                type="primary"
                plain
                icon="el-icon-plus"
                size="mini"
                @click="handleAdd"
              >新增</el-button>
            </el-col>
            <el-col :span="1.5">
              <el-button
                type="success"
                plain
                icon="el-icon-edit"
                size="mini"
                :disabled="multiple"
                @click="handleStatusPeople"
              >修改状态</el-button>
            </el-col>
            <el-col :span="1.5" v-if="$store.state.currentJur.isDelFenPei">
                <el-button
                  type="danger"
                  plain
                  icon="el-icon-delete"
                  size="mini"
                  :disabled="multiple"
                  @click="handleDelPeopFenpei"
                >删除人员分配</el-button>
            </el-col>
            
            <!--<el-col :span="1.5">
              <el-button
                type="danger"
                plain
                icon="el-icon-delete"
                size="mini"
                :disabled="multiple"
                @click="handleDelete"
              >删除</el-button>
            </el-col>-->
            <el-col :span="1.5" v-if="$store.state.currentJur.isIn">
              <el-button
                type="info"
                plain
                icon="el-icon-upload2"
                size="mini"
                @click="handleImport"
              >导入</el-button>
            </el-col>
            <el-col :span="1.5" v-if="$store.state.currentJur.isExport">
              <el-button
                type="warning"
                plain
                icon="el-icon-download"
                size="mini"
                @click="handleExport"
              >导出</el-button>
            </el-col>
          </el-col>
        
          <div class="top-right-btn">
            <el-row :gutter="10">
                <el-col :span="1.5" v-if="$store.state.currentJur.isGenZong">
                  <el-button
                    type="primary"
                    plain
                    icon="el-icon-s-comment"
                    size="mini"
                    :disabled="single"
                    @click="handleFollowInfo"
                  >跟踪信息</el-button>
                </el-col>
                
                <el-col :span="1.5" v-if="$store.state.currentJur.isSuoShu">
                  <el-button
                    type="success"
                    plain
                    icon="el-icon-s-custom"
                    size="mini"
                    :disabled="multiple"
                    @click="handleEditPeople"
                  >修改所属人</el-button>
                </el-col>
                <el-col :span="1.5" v-if="$store.state.currentJur.isSuoShu">
                  <el-button
                    type="success"
                    plain
                    icon="el-icon-user-solid"
                    size="mini"
                    :disabled="multiple"
                    @click="handlePeopleFenpei"
                  >人员分配</el-button>
                </el-col>
                 
            </el-row>
          </div>
        </el-row>

        <el-table v-loading="loading" :data="tableData" @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="50" align="center" />
          <el-table-column label="编号" align="center" key="Id" prop="Id" />
          <el-table-column label="名称" align="center" key="Username" prop="Username" />
          <el-table-column label="性别" align="center" key="Sex" prop="Sex" />
          <el-table-column label="年龄" align="center" key="Age" prop="Age" />
          <!--<el-table-column label="籍贯" align="center" key="Origin" prop="Origin" />-->
          <!-- <el-table-column label="民族" align="center" key="FamilyName" prop="FamilyName" /> -->
          <el-table-column label="来源" align="center" key="Source" prop="Source" />

          <el-table-column label="手机号" align="center" key="Shone" prop="Shone" width="120"/>
          <el-table-column label="身份证" align="center" key="CardID" prop="CardID" :show-overflow-tooltip="true"  width="120"/>
          <el-table-column label="所属单位" align="center" key="CompanyName" prop="CompanyName" :show-overflow-tooltip="true" />
          
          <el-table-column label="所属人" align="center" key="Belongs" prop="Belongs" />
          <el-table-column label="入职项目" align="center" key="EntryProgram" prop="EntryProgram" />
          <el-table-column label="分配人" align="center" key="JobsUser" prop="JobsUser" />


          <el-table-column label="身高" align="center" key="Stature" prop="Stature"  />
          <el-table-column label="体重" align="center" key="Weight" prop="Weight"  />

          <el-table-column label="岗位信息" align="center" key="Position" prop="Position"  />
          

          <el-table-column label="报到时间" align="center" prop="TeportTime" width="160" />
          <el-table-column label="状态" align="center" key="Status" width="150">
            <template slot-scope="scope">
               <el-link :underline="false"
              :type="(scope.row.Status == '已入职' || scope.row.Status == '在职') ? 'success' : (scope.row.Status=='离职'?'error':'warning')"
              >{{scope.row.Status}}</el-link :underline="false">
            </template>
          </el-table-column>
          <el-table-column label="备注" align="center" key="Notes" prop="Notes"  />
          <el-table-column
            label="操作"
            align="center"
            width="180"
            class-name="small-padding fixed-width"
          >
            <template slot-scope="scope">
              <el-button v-if="$store.state.currentJur.isEdit"
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdate(scope.row)"
              >编辑</el-button>
              <el-button v-if="$store.state.currentJur.isDel"
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="handleDelete(scope.row)"
              >删除</el-button>
              <el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)"  v-if="$store.state.currentJur.isGenZong || $store.state.currentJur.isSuoShu || $store.state.currentJur.isStatus || $store.state.currentJur.isPeopFenPei || $store.state.currentJur.isDelFenPei">
                <span class="el-dropdown-link">
                  <i class="el-icon-d-arrow-right el-icon--right"></i>更多
                </span>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item command="handleFollowInfo" icon="el-icon-s-comment" v-if="$store.state.currentJur.isGenZong"
                    >跟踪信息</el-dropdown-item>
                  <el-dropdown-item command="handleEditPeople" icon="el-icon-s-custom" v-if="$store.state.currentJur.isSuoShu"
                    >修改所属人</el-dropdown-item>
                  <el-dropdown-item command="handleStatusPeople" icon="el-icon-edit" v-if="$store.state.currentJur.isStatus"
                    >修改状态</el-dropdown-item>
                  <el-dropdown-item command="handlePeopleFenpei" icon="el-icon-user-solid" v-if="$store.state.currentJur.isPeopFenPei"
                    >人员分配</el-dropdown-item>
                  <el-dropdown-item command="handleDelPeopFenpei" icon="el-icon-delete" v-if="$store.state.currentJur.isDelFenPei"
                    >删除人员分配</el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
            </template>
          </el-table-column>
        </el-table>

        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.page"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
         <!-- 添加或修改用户配置对话框 -->
        <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
        <el-form ref="form" :model="form" :rules="rules" label-width="80px">
            <el-row>
                <el-col :span="12">
                    <el-form-item label="名称" prop="username">
                    <el-input v-model="form.username" placeholder="请输入名称" maxlength="30" />
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="手机号" prop="shone">
                    <el-input v-model="form.shone" placeholder="请输入手机号" />
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="身份证" prop="card_id">
                    <el-input v-model="form.card_id" placeholder="请输入身份证" @change="idChange"/>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="性别" prop="sex">
                      <el-select v-model="form.sex" placeholder="请选择性别">
                        <el-option key="1" label="男" value="男"></el-option>
                        <el-option key="2" label="女" value="女"></el-option>
                      </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="年龄" prop="age">
                    <el-input v-model="form.age" placeholder="请输入年龄" :disabled="isDisabled"/>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="籍贯" prop="origin">
                    <el-input v-model="form.origin" placeholder="请输入籍贯" :disabled="isDisabled" maxlength="30" />
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="民族" prop="family_name">
                    <el-input v-model="form.family_name" placeholder="请输入民族" maxlength="30" />
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="身高" prop="stature">
                    <el-input v-model="form.stature" placeholder="请输入身高" maxlength="30" />
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="体重" prop="weight">
                    <el-input v-model="form.weight" placeholder="请输入体重" maxlength="30" />
                    </el-form-item>
                </el-col>
                
                
                
                
                <el-col :span="12">
                    <el-form-item label="岗位信息" prop="position">
                      <!--<el-select v-model="form.position" placeholder="请选择岗位信息">
                        <el-option
                        v-for="item in positionOptions"
                        :key="item.id"
                        :label="item.name"
                        :value="item.id"
                        ></el-option>
                    </el-select>-->
                    <el-input v-model="form.position" placeholder="请输入岗位信息" />
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="入职项目" prop="EntryProgram">
                    <el-input v-model="form.EntryProgram" placeholder="请输入入职项目" />
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="来源" prop="source">
                    <el-input v-model="form.source" placeholder="请输入来源" maxlength="30" />
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="所属单位">
                    <el-select v-model="form.company_id" placeholder="请选择单位">
                        <el-option
                            v-for="item in companyOptions"
                            :key="item.ID"
                            :label="item.Name"
                            :value="item.ID"
                          ></el-option>
                    </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="报到时间" prop="teport_time">
                    <el-date-picker clearable size="small"  style="width: 100%;"
                      v-model="form.teport_time"
                      type="datetime"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      placeholder="请选择报到时间">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="疫苗" prop="vaccinum">
                      <el-input v-model="form.vaccinum" placeholder="请输入疫苗" />
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="备注">
                    <el-input v-model="form.notes" type="textarea" placeholder="请输入内容"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
              <el-col><el-divider content-position="left">跟踪信息</el-divider></el-col>
              <el-col>
                <el-descriptions class="margin-top"  :column="4" size="mini" border>
                    <el-descriptions-item v-for="(item,index) in JobsTrackss" :key="index">
                      <template slot="label">
                        <!-- <i class="el-icon-user"></i>-->
                        <!--{{index + 1}}-->
                        {{parseTime(item.CreateTime,'{y}-{m}-{d} {h}:{i}')}}
                      </template>
                      {{item.TakeNotes}}
                    </el-descriptions-item>
                </el-descriptions>
              </el-col>
              <el-col><el-divider content-position="left">修改信息</el-divider></el-col>
              <el-col>
                <el-descriptions class="margin-top"  :column="3" size="mini" border>
                    <el-descriptions-item v-for="(item,index) in JobsRecords" :key="index">
                      <template slot="label">
                        <!-- <i class="el-icon-user"></i>-->
                        {{index + 1}}
                      </template>
                      {{item.Logs}}
                    </el-descriptions-item>
                </el-descriptions>
              </el-col>
            </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="submitForm">确 定</el-button>
            <el-button @click="cancel">取 消</el-button>
        </div>
        </el-dialog>
        <!--修改状态-->
        <el-dialog title="修改状态" :visible.sync="statusOpen" width="400px" append-to-body>
          <el-form ref="statusForm" :model="statusForm" :rules="statusRules" label-width="80px">
            <el-row>
                <el-col :span="24">
                    <el-form-item label="状态" prop="status_id">
                      <el-select v-model="statusForm.status_id" placeholder="请选择状态">
                          <el-option
                          v-for="item in statusOptions"
                          :key="item.Id"
                          :label="item.Name"
                          :value="item.Id"
                          ></el-option>
                      </el-select>
                    </el-form-item>
                </el-col>
            </el-row>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="statuSubmitForm">确 定</el-button>
            <el-button @click="statusCancel">取 消</el-button>
          </div>
        </el-dialog>

        <!-- 用户导入对话框 -->
        <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
          <el-upload
            ref="upload"
            :limit="1"
            accept=".xlsx, .xls"
            :headers="upload.headers"
            :action="upload.url"
            :disabled="upload.isUploading"
            :on-progress="handleFileUploadProgress"
            :on-success="handleFileSuccess"
            :auto-upload="false"
            drag
          >
            <i class="el-icon-upload"></i>
            <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
            <div class="el-upload__tip text-center" slot="tip">
              <div class="el-upload__tip" slot="tip">
                 <!--<el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据-->
              </div>
              <span>仅允许导入xls、xlsx格式文件。</span>
              <!-- <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>-->
            </div>
          </el-upload>
          <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="submitFileForm">确 定</el-button>
            <el-button @click="upload.open = false">取 消</el-button>
          </div>
        </el-dialog>
        <!--修改所属人-->
        <el-dialog title="修改所属人" :visible.sync="peopOpen" width="400px" append-to-body>
             <el-form ref="peopleForm" :model="peopleForm" :rules="peopRules" label-width="80px">
                <el-row>
                  <el-col :span="24">
                    <el-form-item label="所属人" prop="jobs_id">
                      <el-select v-model="peopleForm.jobs_id" placeholder="请选择所属人">
                          <el-option
                          v-for="item in peoplesOptions"
                          :key="item.ID"
                          :label="item.UserName"
                          :value="item.ID"
                          ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
             </el-form>
             <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="peopleSubmitForm">确 定</el-button>
                <el-button @click="peopleCancel">取 消</el-button>
              </div>
        </el-dialog>
        <!--人员分配-->
        <el-dialog :title="peopFenPeiTitle" :visible.sync="peopFenPeiOpen" width="400px" append-to-body>
             <el-form ref="peopFenPeiForm" :model="peopFenPeiForm" :rules="peopFenPeiRules" label-width="80px">
                <el-row>
                  <el-col :span="24">
                    <el-form-item label="人员分配" prop="jobs_id">
                      <el-select v-model="peopFenPeiForm.jobs_id" placeholder="请选择分配人员">
                          <el-option
                          v-for="item in peoplesOptions"
                          :key="item.ID"
                          :label="item.UserName"
                          :value="item.ID"
                          ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
             </el-form>
             <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="peopFenPeiTitle=='人员分配'?peopFenPeiSubmitForm():delPeopFenPeiSubmitForm()">确 定</el-button>
                <el-button @click="peopFenPeiOpen = false">取 消</el-button>
              </div>
        </el-dialog>
</div>
</template>
<script>
    import Treeselect from "@riophae/vue-treeselect";
    import "@riophae/vue-treeselect/dist/vue-treeselect.css";
    export default {
        name: 'user_manage',
        components: { Treeselect },
        data() {
            return {
              isExpand: false,
                // 查询参数
                queryParams: {
                    page: 1,
                    pageSize: 10,
                    name: '',
                    shone: '',
                    cardId:'',
                    entryProgram:'',
                    company_id:'',user_id:'',
                    stateTime: '',
                    endTime:'',
                    statusId:'',sex:''
                },
                // 遮罩层
                loading: false,
                // 选中数组
                ids: [],names:[],
                // 非单个禁用
                single: true,
                // 非多个禁用
                multiple: true,
                dateRange: [],
                isDisabled: false,  //  身份证获取年龄/年龄/籍贯
                //  表单参数
                form: {},statusForm:{},
                // 总条数
                total: 0,
                // 用户表格数据
                tableData: [],JobsTrackss:[],JobsRecords:[],qiuzhiOptions:[],
                // 弹出层标题
                title: "",
                open: false,statusOpen: false,
                originOptions:[{
                  id: 1,name: '58同城',
                },{
                  id: 2,name: 'BOSS直聘',
                },{
                  id: 3,name: '智联招聘',
                },{
                  id: 4,name: '店长推荐',
                },{
                  id: 5,name: '朋友推荐',
                },{
                  id: 6,name: '其它',
                },{
                  id: 7,name: '抖音',
                },{
                  id: 8,name: '快手',
                }],
                //  职位
                positionOptions:[{
                  id:1,
                  name: '总公司经理'
                },{
                  id:2,
                  name: '主管'
                },{
                  id:3,
                  name: '面试官'
                },{
                  id:4,
                  name: '人事'
                },{
                  id:5,
                  name: '驻场'
                }],
                deptOptions:[
                    {
                        id:0,label:'总公司',
                        children:[{id:10,label:'总公司经理'},{id:11,label:'驻场'},{id:12,label:'分公司'},{id:13,label:'代理权限'}]},
                    {id:1,label:'加盟商',children:[]},
                ],
                companyOptions:[],peoplesOptions:[],peopOpen:false,peopleForm:{},peopleId:'',
                peopFenPeiOpen: false,peopFenPeiForm:{},peopFenPeiId:'',peopFenPeiTitle:'',delPeopFenPeiId:'',
                //  状态组
                statusOptions:[],
                 // 表单校验

                rules: {
                    username: [
                    { required: true, message: "名称不能为空", trigger: "blur" },
                    { min: 2, max: 20, message: '用户名称长度必须介于 2 和 20 之间', trigger: 'blur' }
                    ],
                    age: [
                    // { required: true, message: "年龄不能为空", trigger: "blur" },
                    // { type: 'string',min: 0, message: '年龄输入有误', trigger: 'blur' }
                    ],
                    stature: [
                    // { required: true, message: "身高不能为空", trigger: "blur" },
                    // { type: 'string',min: 0, message: '身高输入有误', trigger: 'blur' }
                    ],
                    // email: [
                    // {
                    //     type: "email",
                    //     message: "请输入正确的邮箱地址",
                    //     trigger: ["blur", "change"]
                    // }
                    // ],
                    card_id: [
                      // { required: true, message: "身份证号不能为空", trigger: "blur" },
                      {pattern:  /^\d{6}(18|19|20)?\d{2}(0[1-9]|1[0-2])(([0-2][1-9])|10|20|30|31)\d{3}(\d|X|x)$/,message:'身份证号格式有误',trigger: 'blur'}
                    ],
                    shone: [
                        { required: true, message: "电话不能为空", trigger: "blur" },
                        {
                            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
                            message: "请输入正确的手机号码",
                            trigger: "blur"
                        }
                    ]
                },
                peopRules:{
                  jobs_id:[
                    { required: true, message: "请选择所属人", trigger: "change" },
                  ]
                },
                peopFenPeiRules:{
                  jobs_id:[
                    { required: true, message: "请选择人员", trigger: "change" },
                  ]
                },
                statusRules: {
                  status_id:[
                    { required: true, message: "状态不能为空", trigger: "change" },
                  ]
                },
                 // 用户导入参数
                upload: {
                  // 是否显示弹出层（用户导入）
                  open: false,
                  // 弹出层标题（用户导入）
                  title: "",
                  // 是否禁用上传
                  isUploading: false,
                  // 是否更新已经存在的用户数据
                  // updateSupport: 0,
                  // 设置上传的请求头部
                  headers: { Authorization: this.$store.state.token},
                  // 上传的地址
                  url: this.GLOBAL.REQUESTURL + "/api/upload"
                },
            }
        },
        created() {
            this.getList();
            this.handleCompony();
            this.handleQiuZhi();
            this.handlePeoples();
        },
        mounted() {
        },
        methods: {
            handleQuery() {
                this.queryParams.page = 1;
                this.getList();
            },
            /** 重置按钮操作 */
            resetQuery() {
                this.dateRange = [];
                this.resetForm("queryForm");
                this.handleQuery();
            },
            getList() {
                const this_ = this
                this_.$http.get(this_.GLOBAL.REQUESTURL + "/api/jobs",{
                    page: this_.queryParams.page,
                    pageSize: this_.queryParams.pageSize,
                    name: this_.queryParams.name,
                    shone: this_.queryParams.shone,
                    cardId: this_.queryParams.cardId,
                    entryProgram: this_.queryParams.entryProgram,
                    company_id:this_.queryParams.company_id,
                    user_id:this_.queryParams.user_id,
                    statusId: this_.queryParams.statusId,
                    sex: this_.queryParams.sex,
                    stateTime: (this_.dateRange&&this_.dateRange.length>0)?parseInt(new Date(this_.dateRange[0]).getTime() / 1000):'',
                    endTime: (this_.dateRange&&this_.dateRange.length>0)?parseInt(new Date(this_.dateRange[1]).getTime() / 1000):''
                })
                .then(res => {
                    this_.tableData = res.data.jobslist; //给查询列表赋值
                    this_.total = res.data.total;
                    this_.loading = false;
                })
                .catch(function(err) {
                    this_.tableData = [];
                    this_.total = 0;
                    this_.loading = false;
                });

            },
            //  根据身份证获取信息
            idChange(val) {
              const self__ = this;
              console.log(val)
              this.$http.get(this.GLOBAL.REQUESTURL + "/api/checkCardId?cardId="+val)
                .then(res => {
                    console.log(res)
                    if(res.code==200){
                      const Data = res.data;
                      self__.form.age = Data.Age;
                      self__.form.sex = Data.Sex;
                      self__.form.origin = Data.Origin;
                      self__.isDisabled = true;
                    } else {
                      self__.form.age = '';
                      self__.form.sex = '';
                      self__.form.origin = '';
                      self__.isDisabled = false;
                    }
                }).catch(err=>{
                  console.log(err)
                  self__.form.age = '';
                  self__.form.sex = '';
                  self__.form.origin = '';
                  self__.isDisabled = false;
                })
            },
            //  获取所属人
            handlePeoples() {
                this.$http.get(this.GLOBAL.REQUESTURL + "/api/userall")
                .then(res => {
                    this.peoplesOptions = res.data;
                }).catch(err=>{
                  console.log(err)
                })
            },
            //  求职者状态
            handleQiuZhi() {
                this.$http.get(this.GLOBAL.REQUESTURL + "/api/jobsStatus")
                .then(res => {
                    this.statusOptions = res.data;
                }).catch(err=>{
                  console.log(err)
                })
            },
             //  获取部门
            handleCompony() {
                const this_ = this
                this_.$http.get(this_.GLOBAL.REQUESTURL + "/api/company?page=1&pageSize=100&name=")
                .then(res => {
                    this_.companyOptions = res.data.comlist;
                })
            },
            //  跟踪信息
            handleFollowInfo(row) {
              const followId = row.Id || this.ids;
              const names = row.Username || this.names;
              const self_ = this;
              this.$prompt('请输入跟踪信息', "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                closeOnClickModal: false,
                inputPattern: /^.+$/,       //  非空验证
                inputErrorMessage: "请输入跟踪信息"
              }).then(({ value }) => {
                  self_.$http.post(self_.GLOBAL.REQUESTURL+"/api/tracks/"+followId,{
                    takenotes: value
                  })
                  .then(res=>{
                    self_.$modal.msgSuccess(res.msg)

                  }).catch(err=>{

                  })
                    // this.$modal.msgSuccess("修改成功，新密码是：" + value);
                }).catch(() => {});
            },
            // 更多操作触发
            handleCommand(command, row) {
              switch (command) {
                case "handleFollowInfo":
                  this.handleFollowInfo(row);
                  break;
                case "handleEditPeople":
                  this.handleEditPeople(row);
                  break;
                case "handleStatusPeople":
                  this.handleStatusPeople(row);
                  break;
                case "handlePeopleFenpei":
                  this.handlePeopleFenpei(row);
                  break;
                case "handleDelPeopFenpei":
                  this.handleDelPeopFenpei(row);
                  break;
                default:
                  break;
              }
            },
            //  修改所属人
            handleEditPeople(row) {
              const _self = this
              _self.peopleId = row.Id || this.ids;
              _self.peopOpen = true;
              /**
              this.$prompt('请输入所属人', "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                closeOnClickModal: false,
                inputPattern: /^.+$/,       //  非空验证
                inputErrorMessage: "请输入所属人"
              }).then(({ value }) => {
                  _self.$http.post(_self.GLOBAL.REQUESTURL+"/api/jobsId",{
                    "user_id": localStorage.getItem("ID"),
                    "jobs_id":_self.ids
                  }).then(res=>{
                    console.log(res)
                    _self.$modal.msgSuccess("修改成功，新密码是：" + value);
                  }).catch(err=>{
                    _self.$modal.msgSuccess("修改成功，新密码是：" + value);
                  })
                }).catch(() => {});
                ***/
            },
            //  修改状态
            handleStatusPeople(row) {
                this.statusOpen = true;
                this.statusForm.id = row.Id || this.ids;
            },
            //  人员分配
            handlePeopleFenpei(row) {
              this.peopFenPeiTitle = '人员分配';
              this.peopFenPeiId = row.Id || this.ids;
              this.peopFenPeiOpen = true;
            },
            handleDelPeopFenpei(row) {
              this.peopFenPeiTitle = '删除人员分配';
              this.delPeopFenPeiId = row.Id || this.ids;
              this.peopFenPeiOpen = true;
            },
            handleAdd() {
                this.reset();
                this.title = "添加信息";
                this.open = true;
            },
            /** 修改按钮操作 */
            handleUpdate(row) {
                const that = this;
                this.reset();
                this.open = true;
                this.title = "修改信息";
                this.form.editId = row.Id || this.ids;
                this.$http.get(this.GLOBAL.REQUESTURL+"/api/jobs/"+this.form.editId)
                .then(res=>{
                  that.form.username= res.data.Username;
                  that.form.shone= res.data.Shone;
                  that.form.card_id= res.data.CardID;
                  that.form.sex= res.data.Sex;
                  that.form.age= res.data.Age;
                  that.form.origin= res.data.Origin;
                  that.form.family_name= res.data.FamilyName;
                  that.form.stature=res.data.Stature;
                  that.form.weight= res.data.Weight;
                  that.form.position= res.data.Position;
                  that.form.EntryProgram = res.data.EntryProgram;
                  that.form.source = res.data.Source;
                  that.form.company_id = res.data.CompanyID;
                  that.form.teport_time= that.parseTime(res.data.TeportTime);
                  that.form.vaccinum = res.data.Vaccinum;
                  that.form.notes= res.data.Notes;
                  that.JobsTrackss = res.data.JobsTrackss;
                  that.JobsRecords = res.data.JobsRecords;
                }).catch(err=>{

                })
            },
            handleDelete(row) {
                const _self = this;
                const delIds = row.Id || this.ids;
                this.$modal.confirm('确认要删除"' + row.Name + '"吗？').then(function() {
                   _self.$http.deleteFn(_self.GLOBAL.REQUESTURL+"/api/jobs/"+row.Id).then(res=>{
                        _self.$modal.msgSuccess( "删除成功");
                        _self.queryParams.page = 1;
                        _self.getList();
                    }).catch(function() {
                        _self.$modal.msgWarning( "删除失败");
                    });  
                }).catch(function() {
                    // _self.$modal.msgWarning( "删除失败");
                });
            },
            submitForm: function() {
                const _this = this
                this.$refs["form"].validate(valid => {
                    if (valid) {
                        if (this.form.editId != undefined) {
                            _this.$http.put(_this.GLOBAL.REQUESTURL+"/api/jobs/"+_this.form.editId,{
                              age:String(_this.form.age),
                              card_id:String(_this.form.card_id),
                              family_name:String(_this.form.family_name),
                              notes: String(_this.form.notes),
                              origin:String(_this.form.origin),
                              position:String(_this.form.position),
                              EntryProgram: String(_this.form.EntryProgram),
                              sex:_this.form.sex,
                              shone:String(_this.form.shone),
                              stature:String(_this.form.stature),
                              teport_time:parseInt(new Date(_this.form.teport_time).getTime() / 1000),
                              username:_this.form.username,
                              weight: String(_this.form.weight),
                              source: String(_this.form.source),
                              vaccinum: String(_this.form.vaccinum)
                            })
                            .then(res => {
                                if(res.code==200){
                                    _this.$modal.msgSuccess(res.msg);
                                } else {
                                    _this.$modal.msgWarning(res.msg);
                                }
                                _this.open = false;
                                _this.getList();
                            })

                        } else {  //_this.form
                            _this.$http.post(_this.GLOBAL.REQUESTURL+"/api/jobs",{
                              age:String(_this.form.age),
                              card_id:String(_this.form.card_id),
                              company_id: String(_this.form.company_id),
                               family_name:String(_this.form.family_name),
                              notes: String(_this.form.notes),
                              origin:String(_this.form.origin),
                              position:String(_this.form.position),
                              EntryProgram:String(_this.form.EntryProgram),
                              sex: _this.form.sex,
                              shone:String(_this.form.shone),
                              stature:String(_this.form.stature),
                              source: String(_this.form.source),
                              teport_time:parseInt(new Date(_this.form.teport_time).getTime() / 1000),
                              username: _this.form.username,
                              vaccinum: String(_this.form.vaccinum),
                              weight: String(_this.form.weight),
                            })
                            .then(res => {
                                if(res.code==200){
                                    _this.$modal.msgSuccess(res.msg);
                                } else {
                                    _this.$modal.msgWarning(res.msg);
                                }
                                _this.open = false;
                                _this.getList();
                            }).catch(err=> {
                                _this.$modal.msgError('新增失败!');
                            })
                        }
                    }
                })
            },
            //  修改状态
            statuSubmitForm() {
              const self_ = this;
              self_.$refs["statusForm"].validate(valid => {
                    if (valid) {
                      var statuSubmitId = self_.statusForm.id;
                      if(Array.isArray(statuSubmitId) == false) {
                        self_.statusForm.id = (String(statuSubmitId).split(',').map(Number));
                      };
                      self_.$http.patch(self_.GLOBAL.REQUESTURL+"/api/jobsStatus/"+self_.statusForm.status_id,{
                      jobs_id: self_.statusForm.id
                      })
                      .then(res=>{
                        self_.statusOpen = false;
                        if(res.code==200) {
                          self_.$modal.msgSuccess(res.msg);
                          self_.getList();
                        }else{
                          self_.$modal.msgWarning(res.msg);
                        }
                      }).catch(err => {

                      })
                    }
              })
            },
            //  所属人修改提交
            peopleSubmitForm() {
              const __self = this;
              this.$refs["peopleForm"].validate(valid=>{
                if(valid) {
                  
                  if(Array.isArray(__self.peopleId) == false) {
                    __self.peopleId = (String(__self.peopleId).split(',').map(Number));
                  };
                    __self.$http.post(__self.GLOBAL.REQUESTURL+"/api/jobsId",{
                      // jobs_id: __self.ids,
                      jobs_id: __self.peopleId,
                      user_id: __self.peopleForm.jobs_id
                    })
                    .then(res=>{
                      if(res.code==200) {
                        __self.$modal.msgSuccess(res.msg)
                      } else {
                        __self.$modal.msgWarning(res.msg)
                      }
                      __self.peopOpen = false;
                      __self.getList();

                    }).catch(err=>{

                    })
                }
              })
            },
            //  人员分配提交
            peopFenPeiSubmitForm() {
              const self = this;
              self.$refs["peopFenPeiForm"].validate(valid=>{
                if(valid) {
                  if(Array.isArray(self.peopFenPeiId) == false) {
                    self.peopFenPeiId = (String(self.peopFenPeiId).split(',').map(Number));
                  };
                    self.$http.post(self.GLOBAL.REQUESTURL+"/api/userJobs",{
                      jobsId: self.peopFenPeiId,
                      userId: self.peopFenPeiForm.jobs_id
                    })
                    .then(res=>{
                      if(res.code==200) {
                        self.$modal.msgSuccess(res.msg)
                      } else {
                        self.$modal.msgWarning(res.msg)
                      }
                      self.peopFenPeiOpen = false;
                      self.getList();
                    }).catch(err=>{

                    })
                }
              })
            },
            //  删除人员分配提交
            delPeopFenPeiSubmitForm() {
              const self = this;
              self.$refs["peopFenPeiForm"].validate(valid=>{
                if(valid) {
                  if(Array.isArray(self.delPeopFenPeiId) == false) {
                    self.delPeopFenPeiId = (String(self.delPeopFenPeiId).split(',').map(Number));
                  };
                  self.axios.delete(self.GLOBAL.REQUESTURL+"/api/userJobs",{
                    data:{
                      jobsId: self.delPeopFenPeiId,
                      userId: self.peopFenPeiForm.jobs_id,
                    }
                  })
                    // self.$http.deleteFn(self.GLOBAL.REQUESTURL+"/api/userJobs",{
                    // jobsId: self.delPeopFenPeiId,userId: self.peopFenPeiForm.jobs_id,
                    // },headers:{'Content-Type': 'application/json'})
                    .then(res=>{
                      const Data = res.data;
                      if(Data.code==200) {
                        self.$modal.msgSuccess(Data.msg)
                      } else {
                        self.$modal.msgWarning(Data.msg)
                      }
                      self.peopFenPeiOpen = false;
                      self.getList();
                    }).catch(err=>{

                    })
                }
              })
            },
            
             /** 导入按钮操作 */
            handleImport() {
              this.upload.title = "用户导入";
              this.upload.open = true;
            },
            // 文件上传中处理
            handleFileUploadProgress(event, file, fileList) {
              this.upload.isUploading = true;
            },
            // 文件上传成功处理
            handleFileSuccess(response, file, fileList) {
              this.upload.open = false;
              this.upload.isUploading = false;
              this.$refs.upload.clearFiles();
              const tableData = response.data;
              var thead = '<thead><tr><td>手机号</td><td>身份证号</td></tr></thead>';
              var tbody = '<tbody>';
              tableData.forEach(function(item) {
                  tbody+='<tr><td>'+item.shone+'</td><td>'+item.cardId+'</td></tr>'
              })
              var html = '<table>'+thead +tbody+'</tbody></table>';
              console.log(html)
              this.$alert("< style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.code==200?response.msg:response.msg+"<div style='height:200px;overflow:auto;'>"+html+"</div>" + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
              this.getList();
            },
            // 提交上传文件
            submitFileForm() {
              this.$refs.upload.submit();
            },
            handleExport1() {
              this.download(this.GLOBAL.REQUESTURL+'/api/download', {
                  ...this.queryParams
                }, `求职者信息_${new Date().getTime()}.xlsx`)
            },
            handleExport() {
                const self_ = this
                this.axios.get(this.GLOBAL.REQUESTURL + 
                    "/api/download?name="+self_.queryParams.name+
                    "&cardId="+self_.queryParams.cardId+
                    "&entryProgram="+self_.queryParams.entryProgram+
                    "&company_id="+self_.queryParams.company_id+
                    "&user_id="+self_.queryParams.user_id+
                    "&shone="+self_.queryParams.shone+
                    "&statusId="+self_.queryParams.statusId+
                    "&sex="+self_.queryParams.sex+
                    "&stateTime="+(self_.dateRange&&self_.dateRange.length>0?parseInt(new Date(self_.dateRange[0]).getTime() / 1000):'')+
                    "&endTime="+(self_.dateRange&&self_.dateRange.length>0?parseInt(new Date(self_.dateRange[1]).getTime() / 1000):''),
                    { responseType: 'arraybuffer' })
                .then(function(res) {
                    if(res) {
                        const aLink = document.createElement("a");
                        let blob = new Blob([res.data], {type: "application/vnd.ms-excel"});
                        let objectUrl = URL.createObjectURL(blob);
                        // window.location.href=objectUrl;
                        aLink.href=objectUrl;
                        aLink.download = '求职者信息';
                        aLink.click();
                        URL.revokeObjectURL(objectUrl);
                    };
                }).catch(function(err) {
                    self.$message.error('导出失败，请刷新重试');
                    self.exportLoading = false;
                })
            },
            // 多选框选中数据
            handleSelectionChange(selection) {
                this.ids = selection.map(item => item.Id);
                this.names = selection.map(item => item.Username);
                this.single = selection.length != 1;
                this.multiple = !selection.length;
            },
             // 取消按钮
            cancel() {
                this.open = false;
                this.reset();
            },
            statusCancel() {
              this.statusOpen = false;
              this.statusForm.status_id = 1;
            },
            peopleCancel() {
              this.peopOpen = false;
            },
            // 用户状态修改
            handleStatusChange(row) {
                let text = row.status === "0" ? "启用" : "停用";
                this.$modal.confirm('确认要"' + text + '""' + row.username + '"用户吗？').then(function() {
                    // return changeUserStatus(row.userId, row.status);
                }).then(() => {
                    this.$modal.msgSuccess(text + "成功");
                }).catch(function() {
                    row.status = row.status === "0" ? "1" : "0";
                });
            },
             // 表单重置
            reset() {
                this.form = {
                    username: '',
                    sex: '',
                    age: '',
                    origin: '',
                    family_name: '',
                    stature: '',
                    weight: '',
                    shone: '',
                    card_id: '',
                    position: '',
                    EntryProgram: '',
                    teport_time: '',
                    notes: '',
                    source: '',
                    vaccinum: ''
                };
                this.resetForm("form");
            },
        }
    }
</script> 